import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class LandlordsSimulate {
    //案例：模拟斗地主
    //需求：通过程序实现斗地主过程中的洗牌，发牌和看牌
    public static void main(String[] args) {
        List<String> CardCase = new ArrayList<>();
        //将牌放入牌盒
        String[] color = {"♥","♠","♣","♦"};
        String[] number = {"2","3","4","5","6","7","8","9","10","J","Q","K","A"};
        for(String s1 : color){
            for(String s2 : number)
                CardCase.add(s1 + s2);
        }
        CardCase.add("Little Joker");
        CardCase.add("Upper Joker");
        /*
        for(String str : CardCase){
            System.out.print(str + " ");
        }
        System.out.println();
        */
        List<String> basecard = new ArrayList<>(); //存放三张底牌
        List<String> player1 = new ArrayList<>();
        List<String> player2 = new ArrayList<>();
        List<String> player3 = new ArrayList<>();
        //洗牌
        Collections.shuffle(CardCase);
        //发牌
        for(int i  = 0; i < CardCase.size(); i++ ){
            if(i >= CardCase.size() - 3)
                basecard.add(CardCase.get(i));
           else  if(i%3 == 0)
                player1.add(CardCase.get(i));
           else if (i%3 == 1)
                player2.add(CardCase.get(i));
           else
                player3.add(CardCase.get(i));

        }
        System.out.println("The base cards are :");
        for(String s : basecard)
            System.out.print(s + " ");
        System.out.println();

        //通过方法实现看牌
        lookPoker("player1",player1);
        lookPoker("player2",player2);
        lookPoker("player3",player3);
        /*
        for(String str : player1)
            System.out.print(str + " ");
        System.out.println();
        for(String str : player2)
            System.out.print(str + " ");
        System.out.println();
        for(String str : player3)
            System.out.print(str + " ");
        System.out.println();
        */

    }

    public static void lookPoker(String name,List<String> card) {
        System.out.println("The poker cards of " + name + " are : " );
        for(String s : card)
            System.out.print(s + " ");
        System.out.println();
    }

}
